package com.itheima.app.controller;

import com.itheima.app.manager.MakeFriendManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author zsk
 * @create 2022-03-20-15:46
 */
@RestController
public class MakeFriendController {

    @Autowired
    private MakeFriendManager makeFriendManager;

    //查询今日佳人
    @GetMapping("/tanhua/todayBest")
    public ResponseEntity findTodayBest() {
        //调用manager
        return makeFriendManager.findTodayBest();
    }

    //推荐朋友
    @GetMapping("/tanhua/recommendation")
    public ResponseEntity findRecommendUserVoByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize
    ) {
        //调用manager
        return makeFriendManager.findRecommendUserVoByPage(pageNum, pageSize);

    }

    //推荐用户详情
    @GetMapping("/tanhua/{jiarenId}/personalInfo")
    public ResponseEntity findPersonalInfo(@PathVariable Long jiarenId) {

        //调用manager
        return makeFriendManager.findPersonalInfo(jiarenId);
    }


    //查询访客记录
    @GetMapping("/movements/visitors")
    public ResponseEntity findVisitors() {
        //调用manager
        return makeFriendManager.findVisitors();
    }

    //上报地理位置
    @PostMapping("/baidu/location")
    public void saveLocation(@RequestBody Map<String,String> param){
        //接收参数
        Double longitude = Double.parseDouble(param.get("longitude"));//接受精度
        Double latitude = Double.parseDouble(param.get("latitude"));//接受纬度
        String addrStr = param.get("addrStr");//位置描述

        //调用manager
        makeFriendManager.saveLocation(longitude,latitude,addrStr);

    }

    //搜索附近
    @GetMapping("/tanhua/search")
    public ResponseEntity searchNearUser(String gender,Long distance){
        //调用manager
        return makeFriendManager.searchNearUser(gender,distance);

    }

    //聊一下查询陌生人问题
    @GetMapping("/tanhua/strangerQuestions")
    public ResponseEntity strangerQuestions(@RequestParam("userId") Long jiarenId){

        //调用manager
        return makeFriendManager.strangerQuestions(jiarenId);

    }

}
